#include <func.h>

void exit_handler1(void)
{
    printf("I am going to die...\n");
}

void exit_handler2(void)
{
    printf("Good bye my friend...\n");
}

int main(int argc, char* argv[])
{
    // 1. 注册退出处理程序
    if (atexit(exit_handler1)) {
        fprintf(stderr, "at_exit() error\n");
        exit(1);
    }

    if (atexit(exit_handler1)) {
        fprintf(stderr, "at_exit() error\n");
        exit(1);
    }

    if (atexit(exit_handler2)) {
        fprintf(stderr, "at_exit() error\n");
        exit(1);
    }

    printf("Begin\n");
    // ...
    printf("End\n");
    // exit(0);
    _exit(0);
}

